<?php

namespace app\model\group_activity;

use app\BaseModel;
use app\model\UserModel;
use think\model\relation\BelongsTo;
use think\model\relation\HasMany;

/**
 * 团体活动-活动报名记录
 */
class GroupActivityTaskUserModel extends BaseModel
{
    protected $name = 'group_activity_task_user';

    /**
     * 用户
     * @return BelongsTo]
     */
    public function user(): BelongsTo
    {
        return $this->belongsTo(UserModel::class,'uid')->bind([
            'user_name' => 'name',
            'avatar',
            'sex',
            'department_id',
            'phone',
            'age',
            'id_card',
            'username',
            'user_number',
            'student_status',
        ]);
    }

    /**
     * 结果
     * @return HasMany
     */
    public function result(): HasMany
    {
        return $this->hasMany(GroupActivityTaskUserResultModel::class,'task_user_id');
    }

    /**
     * 任务
     * @return BelongsTo
     */
    public function task(): BelongsTo
    {
        return $this->belongsTo(GroupActivityTaskModel::class,'task_id')->bind([
            'task_name' => 'name',
            'task_cover' => 'cover',
            'task_type_name' => 'type_name',
            'task_status' => 'status',
            'task_start_time' => 'start_time',
            'task_end_time' => 'end_time',
            'task_time' => 'time',
            'task_address' => 'address',
            'task_is_task' => 'is_task',
            'task_user_name' => 'user_name',
            'task_user_role' => 'user_role',
            'task_max_participation' => 'max_participation',
            'task_enroll_num' => 'enroll_num',
            'task_describe' => 'describe',
            'task_enroll_start_time' => 'enroll_start_time',
            'task_enroll_end_time' => 'enroll_end_time',
            'task_enroll_matters' => 'enroll_matters',
            'task_enroll_review' => 'enroll_review',
            'task_is_sign' => 'is_sign',
            'task_sign_num' => 'sign_num',
            'task_sign_start_time' => 'sign_start_time',
            'task_sign_end_time' => 'sign_end_time',
            'task_sign_matters' => 'sign_matters',
            'task_scheme_file' => 'scheme_file',
            'task_scheme_file_name' => 'scheme_file_name',
            'task_scheme' => 'scheme',
            'task_scheme_matters' => 'scheme_matters',
            'taskRatingScale',
            'taskDepartment'
        ]);
    }
}